#ifndef SYSCALL_H
#define SYSCALL_H

#include "types.h"
#include  <sys/stat.h>

#define SYSCALL_GATE_P       (1<<15) 
#define SYSCALL_GATE_DPL0    (0<<13)
#define SYSCALL_GATE_DPL3    (3<<13)
#define SYSCALL_GATE_TYPE32  (0xC<<8)
#define SYSCALL_GATE_PARAM_COUNT   (5<<0)

#define SYS_sleep 0
#define SYS_printmsg 1
#define SYS_printmsg1 2

#define SYS_getpid 3
#define SYS_fork 4
#define SYS_execve 5
#define SYS_yield 6

#define SYS_open    7
#define SYS_read    8
#define SYS_write   9
#define SYS_close   10
#define SYS_lseek   11

#define SYS_isatty  20
#define SYS_fstat   21
#define SYS_sbrk    22
#define SYS_dup     23
#define SYS_exit    24
#define SYS_wait    25

#define SYS_opendir 26
#define SYS_readdir 27
#define SYS_closedir 28
#define SYS_ioctl    29
#define SYS_unlink   30


typedef struct _syscall_frame_t{
    uint32_t eflags;
    uint32_t gs,fs,es,ds;
    uint32_t edi,esi,ebp,dummy,ebx,edx,ecx,eax;
    uint32_t eip,cs;
    int func_id,arg0,arg1,arg2,arg3;
    uint32_t esp,ss;
}syscall_frame_t;

typedef struct _var_args_t{
    int num_args;
    int args[128];
}var_args;

void exception_handler_syscall(void);  //implemented in start.S

#endif